# @File: login_page.py

import allure
from po.base_page import BasePage
from element.login_operation import LoginPlace


class LoginPage(BasePage):

    def __init__(self, driver):
        super().__init__(driver)
        self.place = LoginPlace()

    @allure.step("执行登录操作")
    def login(self, phone, code):
        self.click_element(self.place.tv_skip)
        self.click_element(self.place.item_me)
        self.slide_top()
        self.click_element(self.place.tv_login)
        self.input_text(self.place.et_phone_num, phone, slow_type=False)
        self.enter_done()
        self.click_element(self.place.btn_obtain_sms)
        self.input_text(self.place.EditText, code, slow_type=False)
        self.click_element(self.place.cb_protocal)
        self.click_element(self.place.tv_mobile_login)
        self.assert_element_exists(self.place.tv_vip_right)


    @allure.step("执行退出操作")
    def logout(self, atext):
        self.click_element(self.place.tv_skip)
        self.click_element(self.place.item_me)
        element = self.scroll_to_element(self.place.tv_text_set)
        element.click()
        self.click_element(self.place.tv_sign_out)
        self.assert_element_text(self.place.assert_tv_sign_out, atext)



